package com.polaris.live.widget.all_chart

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.WidgetAllOrMessageBinding

/**
 * AllChatView
 *
 * @author Created by 半仙 on 2023/11/1/001 16:36
 */
class AllChatView(context: Context, attributeSet: AttributeSet) : FrameLayout(context, attributeSet) {

    private val mBinding = WidgetAllOrMessageBinding.inflate(LayoutInflater.from(context), this)

    private var mOnAllClientListener: (() -> Unit)? = null
    private var mOnChatClientListener: (() -> Unit)? = null

    init {
        mBinding.tvChat.setOnSingleClickListener {
            mBinding.llChat.visibility = View.VISIBLE
            mBinding.llAll.visibility = View.INVISIBLE
            mOnChatClientListener?.invoke()
        }

        mBinding.tvAll2.setOnSingleClickListener {
            mBinding.llChat.visibility = View.INVISIBLE
            mBinding.llAll.visibility = View.VISIBLE
            mOnAllClientListener?.invoke()
        }
    }

    fun setOnAllClientListener(click: () -> Unit) {
        mOnAllClientListener = click
    }

    fun setOnChatClientListener(click: () -> Unit) {
        mOnChatClientListener = click
    }
}